<script src="<?php echo base_url() ?>commons/validacion/js/jquery-1.8.2.min.js" type="text/javascript"></script>
<link href="<?php echo base_url() ?>commons/validacion/css/validationEngine.jquery.css" rel="stylesheet">
<script src="<?php echo base_url() ?>commons/validacion/js/languages/jquery.validationEngine-es.js" type="text/javascript" charset="utf-8"></script>
<script src="<?php echo base_url() ?>commons/validacion/js/jquery.validationEngine.js" type="text/javascript" charset="utf-8"></script>



<script>
    var t = jQuery.noConflict();
    t(document).ready(function() {
        // binds form submission and fields to the validation engine			
        t("#formID").validationEngine();
         t("#formID1").validationEngine();
         t("#formID2").validationEngine();
    });

    /**
     *
     * @param {jqObject} the field where the validation applies
     * @param {Array[String]} validation rules for this field
     * @param {int} rule index
     * @param {Map} form options
     * @return an error string if validation failed
     */
    function checkHELLO(field, rules, i, options) {
        if (field.val() != "HELLO") {
            // this allows to use i18 for the error msgs
            return options.allrules.validate2fields.alertText;
        }
    }
</script>
<link rel="stylesheet" href="<? echo base_url() ?>commons/jquery/themes/base/jquery.ui.all.css">

<script src="<?php echo base_url() ?>commons/jquery/ui/jquery.ui.core.js"></script>
<script src="<?php echo base_url() ?>commons/jquery/ui/jquery.ui.widget.js"></script>
<script src="<?php echo base_url() ?>commons/jquery/ui/jquery.ui.tabs.js"></script>

<script>
    var t1 = jQuery.noConflict();
    t1(function() {
        t1("#tabs").tabs();
    });
</script>
<?php
        $CI = & get_instance();
        echo '<script type="text/javascript">';
        echo 'var t = jQuery.noConflict(); ';
        echo 't(document).ready(function(){
				       setTimeout(function(){ t(".mensajes").fadeOut(800).fadeIn(800).fadeOut(500).fadeIn(500).fadeOut(300);}, 3000); ';
        echo '		});';
        echo '</script>';
        echo validation_errors('<div class="error">', '</div>');
        if ($this->session->flashdata('error')) {
            echo "<div class='error mensajes'>";
            echo $this->session->flashdata('error');
            echo "</div>";
        }
        if ($this->session->flashdata('info')) {
            echo "<div class='info mensajes'>";
            echo $this->session->flashdata('info');
            echo "</div>";
        }
        //alerta
        if ($this->session->flashdata('exito')) {
            echo "<div class='info mensajes'>";
            echo $this->session->flashdata('exito');
            echo "</div>";
        }
        if ($this->session->flashdata('alerta')) {
            echo "<div class='info mensajes'>";
            echo $this->session->flashdata('alerta');
            echo "</div>";
        }
        
            
        ?>
<div id="tabs" >
    
    <ul>
        <li><a href="#tabs-1">Lista de Rubros</a></li>
        
    </ul>
    <div id="tabs-1">
<div id="buscar"  >
    <form class="well form-search" action="<?php echo base_url() . "admin.php/rubro_controlador/buscar" ?>" method="post" >
        <input type="text" class="input-medium search-query" name="txtsearch">
        <button type="submit" class="btn">Buscar</button>
    </form> 
</div>
<div id="agregar">
    <form class="well" action="<?php echo base_url() . "admin.php/rubro_controlador/crear" ?>" method="post" >
        <input class="btn" type="submit"  value="Crear Nuevo Rubro">


    </form> 
</div>
<br/>
<br/>
<br/>
<br/>
<br/>
<div id="tabla" >
    <table class="table table-bordered table-striped table-condensed">
        <caption><h3>LISTADO DE RUBROS </h3></caption>
        <thead>
            <tr>
                <th>Nro</th>
                <th>NOMBRE</th>
                <th>COSTO</th>
                <th>PERIODO LECTIVO</th>
                <th>ESTADO</th>
                <th colspan="2" align ="center">ACCIONES</th>
                
            </tr>
        </thead>
        <tbody>
            <?php
            if (!empty($lista)) {
                $cont=1;
                foreach ($lista as $i => $row) {
                    ?>
                    <tr>
                        <td><?php echo $cont ?></td>
                        <td><?php echo $row['nombre_rubro'] ?></td>
                        <td><?php echo $row['costo_rubro'] ?></td>
                        <td><?php echo $row['descripcion_lec'] ?></td>
                        <td><?php echo ($row['estado_rubro']==true)?'Activo':'Desactivo' ?></td>
                        
                        <td>
                            <a href='<?php echo (base_url() . "admin.php/rubro_controlador/verActualizar/" . $row['ide_rubro']); ?>' >
                                <i class="icon-edit"></i>Edit</a>
                        </td>
                        <td>
                            <?php if($row['estado_rubro']==true){ ?>
                            <a href='<?php echo (base_url() . "admin.php/rubro_controlador/activar_desactivar/" . $row['ide_rubro'].'/'.$row['estado_rubro']); ?>' onclick="return confirm('Desea desactivar el rubro denominado <?php echo $row['nombre_rubro'] ?>')">
                                <i class="icon-remove"></i>Des</a>
                            <?php } else { ?>
                                <a href='<?php echo (base_url() . "admin.php/rubro_controlador/activar_desactivar/" . $row['ide_rubro'].'/'.$row['estado_rubro']); ?>' onclick="return confirm('Desea activar el rubro denominado <?php echo $row['nombre_rubro'] ?>')">
                                <i class="icon-remove"></i>Act</a>
                                <?php } ?>
                            </td>
                    </tr>
                    <?php
                    $cont++;
                }
            }else{
                echo '<tr>';
                echo '<td colspan="6">'. utf8_decode(utf8_encode("No hay ningún rubro creado actualmente")).'</td>';
                echo '</tr>';
            }
            ?>
        </tbody>
    </table>        
</div>
</div>
    <!-- fin del uno-->
    </div>